PHP FOR BEGINNERS AND INTERMEDIATES: PHP, MySQL, JavaScript, Jquery, HTML, CSS everything in just one textbook, December 2015 edition by José Miguel Sánchez

PHP FOR BEGINNERS AND INTERMEDIATES: PHP, MySQL, JavaScript, Jquery, HTML, CSS everything in just one textbook, December 2015 edition by José Miguel Sánchez

Author:José Miguel Sánchez [Sánchez, José Miguel]
Language: eng
Format: azw3, mobi, epub
Published: 2015-12-21T16:00:00+00:00


<body>

<input type = "button" value = "Display greeting" onclick = "hello()" />

</ body>

</ html>

Note:

The document.location.href = "http://www.cnn.com/" command redirects the page to the specified URL, in this case www.cnn.com.

throw Command

This command is used in conjunction with try ... catch to create exception messages, control program flow and generate more precise error messages.

Syntax

throw exception

Example:

We see below a use of the try method under different conditions and throwing different error messages in case any of them fail.

<! DOCTYPE html>

<html>

<body>

<Script type = "text / javascript">

var x = prompt ("Enter number of 1 to 10", "");

try

{

if (x> 5)

{

throw "Err1";

}

else if (x <5)

{

throw "Err2";

}

else if (isNaN(x))

{

throw "Err3";

}

}

catch (err)

{

if (err == "Err1")

{

alert ("! Error number is greater than five");

}

if (err == "Err2")

{

alert ("Error number is less than five!");

}

if (err == "Err3")

{

alert ("Error input is not a number!.");

}

}

</ script>

</ body>

</ html>



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.